﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.IO;
using Styx;
using Styx.Helpers;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;
using Styx.Common;

namespace DWCC
{
    public partial class cfg : Form
    {
        public cfg()
        {
            InitializeComponent();
        }

        private void cfg_Load(object sender, EventArgs e)
        {
            pictureBox1.ImageLocation = Styx.Common.Utilities.AssemblyDirectory + @"\Routines\DWCC v5.0 BT\utils\logo.jpg";
            #region Trinkets
            if (StyxWoW.Me.Inventory.GetItemBySlot(12) != null)
            {
                TrinketOneGroupBox.Text = StyxWoW.Me.Inventory.GetItemBySlot(12).Name;
            }
            else
            {
                UseTrinketOneOnCd.Checked = false;
                UseTrinketOneOnCd.Enabled = false;
                UseTrinketOneHero.Checked = false;
                UseTrinketOneHero.Enabled = false;
                UseTrinketOneBelow20.Checked = false;
                UseTrinketOneBelow20.Enabled = false;
                DoNotUseTrinketOne.Checked = true;
                DoNotUseTrinketOne.Enabled = false;
                UseTrinketOneCC.Checked = false;
                UseTrinketOneCC.Enabled = false;
            }
            if (StyxWoW.Me.Inventory.GetItemBySlot(13) != null)
            {
                TrinketTwoGroupBox.Text = StyxWoW.Me.Inventory.GetItemBySlot(13).Name;
            }
            else
            {
                UseTrinketTwoOnCd.Checked = false;
                UseTrinketTwoOnCd.Enabled = false;
                UseTrinketTwoHero.Checked = false;
                UseTrinketTwoHero.Enabled = false;
                UseTrinketTwoBelow20.Checked = false;
                UseTrinketTwoBelow20.Enabled = false;
                DoNotUseTrinketTwo.Checked = true;
                DoNotUseTrinketTwo.Enabled = false;
                UseTrinketTwoCC.Checked = false;
                UseTrinketTwoCC.Enabled = false;
            }
            #endregion

            DunatanksSettings.Instance.Load();

            #region Specs
            UseArms.Checked = DunatanksSettings.Instance.useArms;
            UseFury.Checked = DunatanksSettings.Instance.useFury;
            UseProt.Checked = DunatanksSettings.Instance.useProt;
            #endregion
            #region Healthstone
            UseHealthStone.Checked = DunatanksSettings.Instance.useHealthStone;
            HealthStonePercent.Value = new decimal(DunatanksSettings.Instance.HealthStonePercent);
            #endregion
            #region Pummel
            UsePummel.Checked = DunatanksSettings.Instance.usePummel;
            #endregion
            #region Taunt
            UseTaunt.Checked = DunatanksSettings.Instance.useTaunt;
            #endregion
            #region Vigilance
            UseVigilance.Checked = DunatanksSettings.Instance.useVigilanceProt;
            UseVigilanceOnRandom.Checked = DunatanksSettings.Instance.useVigilanceOnRandom;
            UseVigilanceOnSpecific.Checked = DunatanksSettings.Instance.useVigilanceOnSpecific;
            VigilanceSpecificName.Text = DunatanksSettings.Instance.VigilanceSpecificName;
            #endregion
            #region Potions
            UsePotion.Checked = DunatanksSettings.Instance.usePotion;
            PotionPercent.Value = new decimal(DunatanksSettings.Instance.PotionPercent);
            #endregion
            #region Trinket One
            UseTrinketOneOnCd.Checked = DunatanksSettings.Instance.UseTrinketOneOnCd;
            UseTrinketOneBelow20.Checked = DunatanksSettings.Instance.UseTrinketOneBelow20;
            UseTrinketOneHero.Checked = DunatanksSettings.Instance.UseTrinketOneHero;
            DoNotUseTrinketOne.Checked = DunatanksSettings.Instance.DoNotUseTrinketOne;
            #endregion
            #region Trinket Two
            UseTrinketTwoOnCd.Checked = DunatanksSettings.Instance.UseTrinketTwoOnCd;
            UseTrinketTwoBelow20.Checked = DunatanksSettings.Instance.UseTrinketTwoBelow20;
            UseTrinketTwoHero.Checked = DunatanksSettings.Instance.UseTrinketTwoHero;
            DoNotUseTrinketTwo.Checked = DunatanksSettings.Instance.DoNotUseTrinketTwo;
            #endregion
            #region Movement
            DisableMovement.Checked = DunatanksSettings.Instance.DisableMovement;
            #endregion
            #region Combat Distance
            CombatDistance.Value = new decimal(DunatanksSettings.Instance.CombatDistance);
            #endregion
            #region Auto-Target
            UseAutoTargetProt.Checked = DunatanksSettings.Instance.useAutoTargetProt;
            #endregion
            #region PvP Trinket
            UseTrinketOneCC.Checked = DunatanksSettings.Instance.useTrinketOneCC;
            UseTrinketTwoCC.Checked = DunatanksSettings.Instance.useTrinketTwoCC;
            #endregion
            #region Rest
            UseRest.Checked = DunatanksSettings.Instance.UseRest;
            RestPercent.Value = new decimal(DunatanksSettings.Instance.RestPercent);
            #endregion

        }

        private void button1_Click(object sender, EventArgs e)
        {
            #region specc
            DunatanksSettings.Instance.useArms = UseArms.Checked;
            DunatanksSettings.Instance.useFury = UseFury.Checked;
            DunatanksSettings.Instance.useProt = UseProt.Checked;
            #endregion
            #region healthstone
            DunatanksSettings.Instance.useHealthStone = UseHealthStone.Checked;
            DunatanksSettings.Instance.HealthStonePercent = (int)HealthStonePercent.Value;
            #endregion
            #region Pummel
            DunatanksSettings.Instance.usePummel = UsePummel.Checked;
            #endregion
            #region Taunt
            DunatanksSettings.Instance.useTaunt = UseTaunt.Checked;
            #endregion
            #region Vigilance
            DunatanksSettings.Instance.useVigilanceProt = UseVigilance.Checked;
            DunatanksSettings.Instance.useVigilanceOnRandom = UseVigilanceOnRandom.Checked;
            DunatanksSettings.Instance.useVigilanceOnSpecific = UseVigilanceOnSpecific.Checked;
            DunatanksSettings.Instance.VigilanceSpecificName = VigilanceSpecificName.Text;
            #endregion
            #region Potions
            DunatanksSettings.Instance.usePotion = UsePotion.Checked;
            DunatanksSettings.Instance.PotionPercent = (int)PotionPercent.Value;
            #endregion
            #region Trinket One
            DunatanksSettings.Instance.UseTrinketOneOnCd = UseTrinketOneOnCd.Checked;
            DunatanksSettings.Instance.UseTrinketOneBelow20 = UseTrinketOneBelow20.Checked;
            DunatanksSettings.Instance.UseTrinketOneHero = UseTrinketOneHero.Checked;
            DunatanksSettings.Instance.DoNotUseTrinketOne = DoNotUseTrinketOne.Checked;
            #endregion
            #region Trinket Two
            DunatanksSettings.Instance.UseTrinketTwoOnCd = UseTrinketTwoOnCd.Checked;
            DunatanksSettings.Instance.UseTrinketTwoBelow20 = UseTrinketTwoBelow20.Checked;
            DunatanksSettings.Instance.UseTrinketTwoHero = UseTrinketTwoHero.Checked;
            DunatanksSettings.Instance.DoNotUseTrinketTwo = DoNotUseTrinketTwo.Checked;
            #endregion
            #region Movement
            DunatanksSettings.Instance.DisableMovement = DisableMovement.Checked;
            #endregion
            #region Combat Distance
            DunatanksSettings.Instance.CombatDistance = (int)CombatDistance.Value;
            #endregion
            #region Auto-Target
            DunatanksSettings.Instance.useAutoTargetProt = UseAutoTargetProt.Checked;
            #endregion
            #region PvP Trinket
            DunatanksSettings.Instance.useTrinketOneCC = UseTrinketOneCC.Checked;
            DunatanksSettings.Instance.useTrinketTwoCC = UseTrinketTwoCC.Checked;
            #endregion
            #region Rest
            DunatanksSettings.Instance.UseRest = UseRest.Checked;
            DunatanksSettings.Instance.RestPercent = (int)RestPercent.Value;
            #endregion
            DunatanksSettings.Instance.Save();
            Logging.Write("Config saved");
            Close();
        }

        private void UseVigilanceOnRandom_CheckedChanged(object sender, EventArgs e)
        {
            if (UseVigilanceOnRandom.Checked == true)
            {
                VigilanceSpecificName.Enabled = false;
            }
            else
            {
                VigilanceSpecificName.Enabled = true;
            }
        }

        private void UseRest_CheckedChanged(object sender, EventArgs e)
        {
            if (UseRest.Checked == true)
            {
                RestPercent.Enabled = true;
            }
            else
            {
                RestPercent.Enabled = false;
            }
        }
    }
}
